package com.lb.videoplay.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.List;

public class BaseFragmentPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> mDataList;
    private boolean isDestroyItem;

    public BaseFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public BaseFragmentPagerAdapter(FragmentManager fm, List<Fragment> dataList, boolean isDestroyItem) {
        super(fm);
        mDataList = dataList;
        this.isDestroyItem = isDestroyItem;
    }

    @Override
    public Fragment getItem(int position) {
        return mDataList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        if (isDestroyItem) {
            super.destroyItem(container, position, object);
        }
    }

    @Override
    public int getCount() {
        return mDataList.size();
    }
}
